package com.erp.erp_servers.warehouse.imp;

import com.erp.erp_dao.warehouse.ITransferDetailDao;
import com.erp.erp_entitys.warehouse.entity.TransferDetailEntity;
import com.erp.erp_servers.warehouse.ITransferDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @ClassName : TransferDetailServiceImp
 * @Description : 调拨明细实现类
 * @Author : lst
 * @Date: 2020-07-31 13:51
 */
@Service
public class TransferDetailServiceImp implements ITransferDetailService {

    /**
     * 调拨明细接口
     */
    private final ITransferDetailDao transferDetailDao;

    @Autowired
    public TransferDetailServiceImp(ITransferDetailDao transferDetailDao) {
        this.transferDetailDao = transferDetailDao;
    }


    /**
     * 通过实体作为筛选条件查询
     *
     * @param transferDetail 实例对象
     * @return 对象列表
     */
    @Override
    public List<TransferDetailEntity> queryAll(TransferDetailEntity transferDetail) {
        return transferDetailDao.queryAll(transferDetail);
    }

    /**
     * 新增数据
     *
     * @param transferDetail 实例对象
     * @return 影响行数
     */
    @Override
    public int insert(TransferDetailEntity transferDetail) {
        return transferDetailDao.insert(transferDetail);
    }

    /**
     * 调拨明细批量新增
     * @param list 新增调拨集合
     * @return 影响行数
     */
    @Override
    public int insertTransferDetailList(List<TransferDetailEntity> list) {
        return transferDetailDao.insertTransferDetailList(list);
    }

    /**
     * 修改数据
     *
     * @param transferDetail 实例对象
     * @return 影响行数
     */
    @Override
    public int update(TransferDetailEntity transferDetail) {
        return transferDetailDao.update(transferDetail);
    }

    /**
     * 通过调拨明细id获取调拨明细对象
     * @param id 调拨明细id
     * @return 调拨明细对象
     */
    @Override
    public TransferDetailEntity getTransferDetailById(Integer id) {
        return transferDetailDao.getTransferDetailById(id);
    }

    /**
     * 通过库存id获取调拨明细对象
     * @param stockId 库存id
     * @return 调拨明细对象集合
     */
    @Override
    public List<TransferDetailEntity> getTransferDetailByStockId(Integer stockId) {
        return transferDetailDao.getTransferDetailByStockId(stockId);
    }

    /**
     * 获取调拨明细
     * @param transferDetail 查询条件
     * @return 调拨明细
     */
    @Override
    public List<TransferDetailEntity> getTransferDetail(TransferDetailEntity transferDetail) {
        return transferDetailDao.getTransferDetail(transferDetail);
    }

    /**
     * 根据外销合同号获取调拨已用数量
     * @param concatNo 外销合同号
     * @return 调拨已用数量
     */
    @Override
    public BigDecimal getTransferQuantityByConcatNo(String concatNo) {
        return transferDetailDao.getTransferQuantityByConcatNo(concatNo);
    }
}
